home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / fsio / fsioFile.h < prev    next >
C/C++ Source or Header  |  1990-12-07  |  8KB  |  211 lines

  1. /*
  2.  * fsioFile.h --
  3.  *
  4.  *    Declarations for regular file access, local and remote.
  5.  *
  6.  * Copyright 1987 Regents of the University of California
  7.  * All rights reserved.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * $Header: /sprite/src/kernel/fsio/RCS/fsioFile.h,v 9.4 90/12/06 21:56:54 jhh Exp $ SPRITE (Berkeley)
  17.  */
  18.  
  19. #ifndef _FSFILE
  20. #define _FSFILE
  21.  
  22. #ifdef KERNEL
  23. #include <fsio.h>
  24. #include <fsutil.h>
  25. #include <fsconsist.h>
  26. #include <fscache.h>
  27. #include <fsioLock.h>
  28. #include <fsNameOps.h>
  29. #else
  30. #include <kernel/fsio.h>
  31. #include <kernel/fsutil.h>
  32. #include <kernel/fsconsist.h>
  33. #include <kernel/fscache.h>
  34. #include <kernel/fsioLock.h>
  35. #include <kernel/fsNameOps.h>
  36. #endif
  37. /*
  38.  * When a regular file is opened state is packaged up on the server
  39.  * and used on the client to set up the I/O handle for the file.
  40.  * This is the 'streamData' generated by Fsio_FileNameOpen and passed to
  41.  * Fsio_FileIoOpen
  42.  */
  43. typedef struct Fsio_FileState {
  44.     Boolean    cacheable;    /* TRUE if the client can cache data blocks */
  45.     int        version;    /* Version number for data block cache */
  46.     int        openTimeStamp;    /* Time stamp used to catch races between
  47.                  * open replies and cache consistency msgs */
  48.     Fscache_Attributes attr;    /* A copy of some file attributes */
  49.     int        newUseFlags;    /* The server may modify the stream use flags.
  50.                  * In particular, the execute bit is stripped
  51.                  * off when directories are opened. */
  52. } Fsio_FileState;
  53.  
  54. /*
  55.  * When a client re-opens a file it sends the following state to the server.
  56.  */
  57. typedef struct Fsio_FileReopenParams {
  58.     Fs_FileID    fileID;        /* File ID of file to reopen. MUST BE FIRST */
  59.     Fs_FileID    prefixFileID;    /* File ID for the prefix of this file. */
  60.     Fsio_UseCounts    use;        /* Reference counts */
  61.     Boolean    flags;        /* FSIO_HAVE_BLOCKS | FS_SWAP */
  62.     int        version;    /* Expected version number for the file. */
  63. } Fsio_FileReopenParams;
  64.  
  65. /*
  66.  * File reopen flags
  67.  *    FSIO_HAVE_BLOCKS    Set when the client has dirty blocks in its cache.
  68.  *        This implies that it ought to be able to continue caching.
  69.  *        A race exists in that another client could open for writing
  70.  *        first, and thus invalidate the first client's data, or another
  71.  *        client could open for reading and possibly see stale data.
  72.  *    FS_SWAP    This stream flag is passed along so the server doesn't
  73.  *        erroneously grant cacheability to swap files.
  74.  *            
  75.  */
  76. #define FSIO_HAVE_BLOCKS        0x1
  77. /*resrv FS_SWAP            0x4000 */
  78.  
  79. /*
  80.  * The I/O descriptor for a local file.  Used with FSIO_LCL_FILE_STREAM.
  81.  */
  82.  
  83. typedef struct Fsio_FileIOHandle {
  84.     Fs_HandleHeader    hdr;        /* Standard handle header.  The
  85.                      * 'major' field of the fileID
  86.                      * is the domain number.  The
  87.                      * 'minor' field is the file num. */
  88.     Fsio_UseCounts        use;    /* Open, writer, and exec counts.
  89.                      * Used for consistency checks. This
  90.                      * is a summary of all uses of a file */
  91.     int            flags;        /* FSIO_FILE_NAME_DELETED and
  92.                      * FSIO_FILE_DESC_DELETED */
  93.     struct Fsdm_FileDescriptor *descPtr;/* Reference to disk info, this
  94.                      * has attritutes, plus disk map. */
  95.     Fscache_FileInfo    cacheInfo;    /* Used to access block cache. */
  96.     Fsconsist_Info    consist;    /* Client use info needed to enforce
  97.                      * network cache consistency */
  98.     Fsio_LockState        lock;        /* User level locking state. */
  99.     Fscache_ReadAheadInfo    readAhead;/* Read ahead info used to synchronize
  100.                      * with other I/O and closes/deletes. */
  101.     struct Vm_Segment    *segPtr;    /* Reference to code segment needed
  102.                      * to flush VM cache. */
  103. } Fsio_FileIOHandle;            /* 268 BYTES (316 with traced locks) */
  104.  
  105. /*
  106.  * Flags for local I/O handles.
  107.  *    FSIO_FILE_NAME_DELETED        Set when all names of a file have been
  108.  *                removed.  This marks the handle for removal.
  109.  *    FSIO_FILE_DESC_DELETED        Set when the disk descriptor is in
  110.  *                the process of being removed.  This guards
  111.  *                against a close/remove race where two parties
  112.  *                try to do the disk deletion phase.
  113.  */
  114. #define FSIO_FILE_NAME_DELETED        0x1
  115. #define FSIO_FILE_DESC_DELETED        0x2
  116.  
  117.  
  118. /*
  119.  * OPEN SWITCH
  120.  * The nameOpen procedure is used on the file server when opening streams or
  121.  * setting up an I/O fileID for a file or device.  It is keyed on
  122.  * disk file descriptor types( i.e. FS_FILE, FS_DIRECTORY, FS_DEVICE,
  123.  * FS_PSEUDO_DEVICE).  The nameOpen procedure returns an ioFileID
  124.  * used for I/O on the file, plus other data needed for the client's
  125.  * stream.  The streamIDPtr is NIL during set/get attributes, which
  126.  * indicates that the extra stream information isn't needed.
  127.  */
  128.  
  129. typedef struct Fsio_OpenOps {
  130.     int        type;            /* One of the file descriptor types */
  131.     /*
  132.      * The calling sequence for the nameOpen routine is:
  133.      *    FooNameOpen(handlePtr, openArgsPtr, openResultsPtr);
  134.      */
  135.     ReturnStatus (*nameOpen) _ARGS_((Fsio_FileIOHandle *handlePtr, 
  136.                      Fs_OpenArgs *openArgsPtr,
  137.                      Fs_OpenResults *openResultsPtr));
  138. } Fsio_OpenOps;
  139.  
  140. extern Fsio_OpenOps fsio_OpenOpTable[];
  141.  
  142. /*
  143.  * Open operations.
  144.  */
  145. extern ReturnStatus Fsio_FileNameOpen _ARGS_((Fsio_FileIOHandle *handlePtr, 
  146.             Fs_OpenArgs *openArgsPtr, 
  147.             Fs_OpenResults *openResultsPtr));
  148.  
  149. /*
  150.  * Stream operations.
  151.  */
  152. extern ReturnStatus Fsio_FileIoOpen _ARGS_((Fs_FileID *ioFileIDPtr,
  153.         int *flagsPtr, int clientID, ClientData streamData, char *name,
  154.         Fs_HandleHeader **ioHandlePtrPtr));
  155. extern ReturnStatus Fsio_FileRead _ARGS_((Fs_Stream *streamPtr,
  156.         Fs_IOParam *readPtr, Sync_RemoteWaiter *remoteWaitPtr, 
  157.         Fs_IOReply *replyPtr));
  158. extern ReturnStatus Fsio_FileWrite _ARGS_((Fs_Stream *streamPtr, 
  159.         Fs_IOParam *writePtr, Sync_RemoteWaiter *remoteWaitPtr, 
  160.         Fs_IOReply *replyPtr));
  161. extern ReturnStatus Fsio_FileIOControl _ARGS_((Fs_Stream *streamPtr, 
  162.         Fs_IOCParam *ioctlPtr, Fs_IOReply *replyPtr));
  163. extern ReturnStatus Fsio_FileSelect _ARGS_((Fs_HandleHeader *hdrPtr, 
  164.         Sync_RemoteWaiter *waitPtr, int *readPtr, int *writePtr, 
  165.         int *exceptPtr));
  166. extern ReturnStatus Fsio_FileMigClose _ARGS_((Fs_HandleHeader *hdrPtr, 
  167.         int flags));
  168. extern ReturnStatus Fsio_FileMigOpen _ARGS_((Fsio_MigInfo *migInfoPtr, int size,
  169.         ClientData data, Fs_HandleHeader **hdrPtrPtr));
  170. extern ReturnStatus Fsio_FileMigrate _ARGS_((Fsio_MigInfo *migInfoPtr, 
  171.         int dstClientID, int *flagsPtr, int *offsetPtr, int *sizePtr, 
  172.         Address *dataPtr));
  173. extern ReturnStatus Fsio_FileReopen _ARGS_((Fs_HandleHeader *hdrPtr, 
  174.         int clientID, ClientData inData, int *outSizePtr, 
  175.         ClientData *outDataPtr));
  176. extern ReturnStatus Fsio_FileBlockCopy _ARGS_((Fs_HandleHeader *srcHdrPtr, 
  177.         Fs_HandleHeader *dstHdrPtr, int blockNum));
  178. extern Boolean Fsio_FileScavenge _ARGS_((Fs_HandleHeader *hdrPtr));
  179.  
  180. #ifdef SOSP91
  181. extern ReturnStatus Fsio_FileClose _ARGS_((Fs_Stream *streamPtr, int clientID,
  182.         Proc_PID procID, int flags, int dataSize,
  183.         ClientData closeData, int *offsetPtr, int *rwFlagsPtr));
  184. #else
  185. extern ReturnStatus Fsio_FileClose _ARGS_((Fs_Stream *streamPtr, int clientID,
  186.         Proc_PID procID, int flags, int dataSize,
  187.         ClientData closeData));
  188. #endif
  189. extern ReturnStatus Fsio_FileCloseInt _ARGS_((Fsio_FileIOHandle *handlePtr,
  190.         int ref, int write, int exec, int clientID, Boolean callback));
  191. extern void Fsio_FileClientKill _ARGS_((Fs_HandleHeader *hdrPtr, int clientID));
  192.  
  193. extern void Fsio_FileSyncLockCleanup _ARGS_((Fsio_FileIOHandle *handlePtr));
  194.  
  195. extern void Fsio_InstallSrvOpenOp _ARGS_((int fileType, 
  196.             Fsio_OpenOps *openOpsPtr));
  197. extern ReturnStatus Fsio_LocalFileHandleInit _ARGS_((Fs_FileID *fileIDPtr,
  198.         char *name, struct Fsdm_FileDescriptor *descPtr,
  199.         Boolean cantBlock, Fsio_FileIOHandle **newHandlePtrPtr));
  200.  
  201. extern ReturnStatus Fsio_DeviceNameOpen _ARGS_((Fsio_FileIOHandle *handlePtr, 
  202.                 Fs_OpenArgs *openArgsPtr, 
  203.                 Fs_OpenResults *openResultsPtr));
  204. /*
  205.  * ftrunc() support
  206.  */
  207. extern ReturnStatus Fsio_FileTrunc _ARGS_((Fsio_FileIOHandle *handlePtr, 
  208.             int size, int flags));
  209.  
  210. #endif _FSFILE
  211.